<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="gly"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
<meta charset="GB18030">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/font-awesome.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/main.css">

</head>
<body style="margin-top: -50px">
	<div class="panel panel-default" style="margin-top: 0px">
		<div class="panel-heading">
			<h3 class="panel-title">
				<i class="glyphicon glyphicon-th"></i> 维修记录
			</h3>
		</div>
		<div class="panel-body">
			<form class="form-inline" role="form" style="float: left;" method="post"
				action="${pageContext.request.contextPath}/repairs/getByCondition">

				<div class="form-group has-feedback">
					<div class="input-group">
						<div class="input-group-addon">车牌号码</div>
						<input class="form-control has-success" type="text"
							placeholder="请输入查询条件，支持模糊查询" name="dr_condition"
							value="${sessionScope.dr_condition}">
					</div>
				</div>
				<button type="submit" class="btn btn-warning" id="search_btn">
					<i class="glyphicon glyphicon-search"></i> 查询
				</button>
			</form>

			<form action="${pageContext.request.contextPath}/repairs/batchDelete"
				method="post">

				<button type="submit" class="btn btn-danger"
					style="float: right; margin-left: 10px;" id="delBreaks_btn">
					<i class=" glyphicon glyphicon-remove"></i> 批量删除
				</button>
				<a class="btn btn-primary" style="float: right; margin-left: 10px;"
					href="${pageContext.request.contextPath}/repairs/add"><span
					class="glyphicon glyphicon-plus"></span>增加</a> <br>
				<hr style="clear: both;">
				<div class="table-responsive">
					<table class="table  table-bordered">
						<thead>
							<tr>
								<th width="30">#</th>
								<th width="30"><input type="checkbox" id="selectAll"></th>
								<th>车牌号码</th>
								<th>修理厂</th>
								<th>送修时间</th>
								<th>预计取车时间</th>
								<th>取车时间</th>
								<th>经办人</th>
								<th>取车时间</th>
								<th>维修金额</th>
								<th width="125">操作</th>
							</tr>
						</thead>
						<!-- 信息展示 -->
						<tbody>
							<gly:forEach items="${pageInfo.list}" var="repairs"
								varStatus="vs">
								<tr>
									<td>${vs.count}</td>
									<td><input type="checkbox" value="${repairs.rpId}"
										name="cb"></td>
									<td>${repairs.rpCarlicense}</td>
									<td>${repairs.rpUnit}</td>

									<td><fmt:formatDate value="${repairs.rpSendtime}"
											pattern="yyyy-MM-dd" /></td>
									<td><fmt:formatDate value="${repairs.rpPlangettime}"
											pattern="yyyy-MM-dd" /></td>
									<td><gly:if test="${repairs.rpGettime == null}">		
											未取车
									</gly:if> <fmt:formatDate value="${repairs.rpGettime}"
											pattern="yyyy-MM-dd" /></td>
									<td>${repairs.rpDriver}</td>
									<td><gly:if test="${repairs.rpGettime == null}">		
											未取车
									</gly:if> <fmt:formatDate value="${repairs.rpGettime}"
											pattern="yyyy-MM-dd" /></td>
									<td><gly:if test="${repairs.rpAmount == null}">		
											未结算
									</gly:if> ${repairs.rpAmount}</td>
									<td>
										<button type="button" class="btn btn-success btn-xs"
											onclick="window.location.href='${pageContext.request.contextPath}/repairs/showInfo?rpId='+${repairs.rpId}">
											<i class=" glyphicon glyphicon-list-alt"></i>
										</button>
										<button type="button" class="btn btn-primary btn-xs"
											onclick="window.location.href='${pageContext.request.contextPath}/repairs/update?rpId='+${repairs.rpId}">
											<i class=" glyphicon glyphicon-pencil"></i>
										</button>
										<button type="button" class="btn btn-danger btn-xs"
											onclick="window.location.href='${pageContext.request.contextPath}/repairs/deleteById?rpId='+${repairs.rpId}">
											<i class=" glyphicon glyphicon-remove"></i>
										</button>
									</td>
								</tr>
							</gly:forEach>


						</tbody>
					</table>
				</div>
			</form>
			<div class="row">
				<!--文字信息-->

				<div align="center">
					<ul class="pagination">

						<li><a
							href="${pageContext.request.contextPath}/repairs/getByCondition?dr_pn=1">首页</a></li>

						<!--上一页-->
						<li><gly:if test="${pageInfo.hasPreviousPage}">
								<a
									href="${pageContext.request.contextPath}/repairs/getByCondition?dr_pn=${pageInfo.pageNum-1}"
									aria-label="Previous"> <span aria-hidden="true">«</span>
								</a>
							</gly:if></li>

						<!--循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接-->
						<gly:forEach items="${pageInfo.navigatepageNums}" var="page_num">
							<gly:if test="${page_num == pageInfo.pageNum}">
								<li class="active"><a href="#">${page_num}</a></li>
							</gly:if>
							<gly:if test="${page_num != pageInfo.pageNum}">
								<li><a
									href="${pageContext.request.contextPath}/repairs/getByCondition?dr_pn=${page_num}">${page_num}</a></li>
							</gly:if>
						</gly:forEach>

						<!--下一页-->
						<li><gly:if test="${pageInfo.hasNextPage}">
								<a
									href="${pageContext.request.contextPath}/repairs/getByCondition?dr_pn=${pageInfo.pageNum+1}"
									aria-label="Next"> <span aria-hidden="true">»</span>
								</a>
							</gly:if></li>

						<li><a
							href="${pageContext.request.contextPath}/repairs/getByCondition?dr_pn=${pageInfo.pages}">尾页</a></li>
					</ul>
				</div>
				<div align="center">当前第 ${pageInfo.pageNum} 页.总共
					${pageInfo.pages} 页.一共 ${pageInfo.total} 条记录</div>
			</div>
		</div>

	</div>

	<!-- 详细信息模态框结束 -->
	<script
		src="${pageContext.request.contextPath}/static/jquery/jquery-2.1.1.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/bootstrap/js/bootstrap.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/script/docs.min.js"></script>
	<script type="text/javascript">
	$(function() {
		var deleterows = '${deleterows}';
		if (deleterows != "") {
			alert("成功删除" + deleterows + "条记录");
		}
		$("#selectAll").change(function() {
			if ($(this).prop('checked') == true) {
				$('input[name="cb"]').each(function() {
					$(this).prop('checked', true);
				})
			} else {
				$('input[name="cb"]').each(function() {
					$(this).prop('checked', false);
				})
			}

		});
		$("#delBreaks_btn").click(function() {
			var flag = false;
			$('input[name="cb"]').each(function() {
				if ($(this).prop('checked') == true) {
					flag = true;
				}
			})
			if (flag == false) {
				alert("请选择删除项目！");
				return false;
			}
			if (confirm("是否删除选中记录?") == false) {
				return false;
			}
		})

	})
	</script>

</body>
</html>